﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MidTest.Library;

namespace MidTest.Main
{
    class Program
    {
        static void Main(string[] args)
        {
            string exitCommand = string.Empty;
            
            Task task = new Task();
            string input = string.Empty;
            int steps;
            string encryptResult = string.Empty;
            string decryptResult = string.Empty;

            while (!exitCommand.Equals("y"))
            {
                Console.WriteLine("\nInput alphanumeric string to be encrypted:");
                input = Console.ReadLine();

                try
                {
                    Console.WriteLine("\nInput number of encryption steps:");
                    string stepsStr = Console.ReadLine();
                    steps = Convert.ToInt32(stepsStr);

                    Console.WriteLine("\ninput : " + input);
                    Console.WriteLine("steps : " + steps);

                    encryptResult = task.Encrypt(input, steps);
                    Console.WriteLine("\nencrypt result : " + encryptResult);

                    decryptResult = task.Decrypt(encryptResult, steps);
                    Console.WriteLine("\ndecrypt result : " + decryptResult);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }

                Console.WriteLine("\nExit application? (press 'y' to exit)");

                exitCommand = Console.ReadLine();
            }
        }
    }
}
